/**
 * xnikt - XSD refactoring tool
 * Copyright (C) 2008 Dharivs from Byte Fo-Ji (http://bytefo-ji.blogspot.com)
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package com.bytefoji.xnikt;

import javolution.text.TextBuilder;

/**
 *
 * @author dharivs
 */
class XSDElement {

    private String name;
    private String tag;
    private int index;
    private String xml;

    XSDElement(String name, int idx, String tag) {
        this.setName(name);
        this.setIndex(idx);
        this.setTag(tag);
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final XSDElement other = (XSDElement) obj;
        if (this.name.equals(other.name) && (this.name == null || !this.name.equals(other.name))) {
            return false;
        }
        if (this.tag.equals(other.tag) && (this.tag == null || !this.tag.equals(other.tag))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 71 * hash + (this.tag != null ? this.tag.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        TextBuilder tb = new TextBuilder();

        tb.append(this.name);
        tb.append("#");
        tb.append(this.tag);

        return tb.toString();
    }

    int getIndex() {
        return this.index;
    }

    Object getName() {
        return this.name;
    }

    String getTag() {
        return this.tag;
    }

    String getXML() {
        return this.xml;
    }

    void setXML(String input_xml) {
        this.xml = input_xml;
    }
}
